package com.bcgtgjyb.huanwen.customview.mylibrary.tool;

/**
 * Rotate 类
 *
 * @since 2016-2-29
 */
public class Rotate {
    private static final int CIRCLEDEGREE = 360;
    private static final int TWO = 2;

    /**
     * rotatePoint 方法
     *
     * @param point 点
     * @param coodinate 座标
     * @param degree 程度
     * @return 0
     */

    public float[] rotatePoint(float[] point, float[] coodinate, int degree) {
        float radioX = coodinate[0];
        float radioY = coodinate[1];
        float xx = point[0];
        float yy = point[1];
        float rr = (float) Math.sqrt((radioX - xx) * (radioX - xx) + (radioY - yy) * (radioY - yy));
        float nowDegree = (float) Math.atan((yy - radioY) / (xx - radioX)) * CIRCLEDEGREE;
        float[] end = new float[TWO];
        float endDegree = nowDegree + degree;
        end[0] = (float) (rr * Math.sin(endDegree / CIRCLEDEGREE));
        end[1] = (float) (rr * Math.cos(endDegree / CIRCLEDEGREE));
        return end;
    }
}
